<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>厦游网-景点管理</title>
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<script type="text/javascript" charset=UTF-8>
	//删除一个
	function deleteOne(mess, url) {
		if (confirm(mess)) {
			location.href = url;
		}
	}
	//删除多个
	function deleteMore(mess, id) {
		if (isSelected()) {
			if (confirm(mess)) {
				var form = document.getElementById(id);
				form.submit();
			}
		} else {
			alert('还未选择要删除的景点！');
		}
	}
	//同时选择多个
	function selectMore(e) {
		var a = document.getElementsByName('items');
		for (var i = 0; i < a.length; i++) {
			a[i].checked = e.checked;
		}
	}

	//判断是否有景点被选中
	function isSelected() {
		var a = document.getElementsByName('items');
		for (var i = 0; i < a.length; i++) {
			if (a[i].checked) {
				return true;
			}
		}
		return false;
	}
</script>
</head>
<body>
	<%@ include file="admin_top_bar.jsp"%>
	<div class="container clearfix">
		<%@ include file="admin_side_bar.jsp"%>
		<!--/sidebar-->
		<div class="main-wrap">
			<div class="crumb-wrap">
				<div class="crumb-list">
					<i class="icon-font"></i><a href="admin_index.jsp">首页</a><span
						class="crumb-step">&gt;</span><span class="crumb-name">景点管理</span>
				</div>
			</div>
			<div class="search-wrap">
				<div class="search-content">
					<form action="AdminGetProduct" method="get">
						<table class="search-tab">
							<tr>
								<th width="10"></th>
								<td><input class="common-text" name="keyword"
									value="${param.keyword}" id="" type="text"
									onkeydown="if(event.keyCode==32){return false;}"></td>
								<td><input class="btn btn-primary btn2" name="sub"
									value="搜索景点" type="submit"></td>
							</tr>
						</table>
					</form>
				</div>
			</div>
			<div class="result-wrap">
				<form name="myform" id="myform" method="post"
					action="AdminProductDelete">
					<div class="result-title">
						<div class="result-list">
							<a href="AdminProductAdd"><i class="icon-font"> </i>新增景点</a> 
							<a id="batchDel" href="javascript:deleteMore('你确定要删除这些商品吗？','myform')"> 
								<i class="icon-font"></i>批量删除
							</a>
						</div>
					</div>
					<div class="result-content">
						<table class="result-tab" style="width: 100%">
							<tr>
								<th class="tc" width="5%"><input class="allChoose" name=""
									onclick="selectMore(this)" type="checkbox"></th>
								<th>景点编号</th>
						        <th>景点名称</th>
						        <th>票价/元</th>
						        <th>景点地址</th>
						        <th>景点预览</th>
						        <th>景点介绍</th>
						        <th>操作</th>
							</tr>
							<c:forEach items="${list}" var="u">
								<tr>
									<td><input type="text" value="${u.sceneryId}" name="id"
								id="id${u.sceneryId}" style="border: none;" /></td>
							<td><input type="text" value="${u.sceneryName}" name="name"
								id="name${u.sceneryId}" style="border: none;" /></td>
							<td><input type="text" value="${u.ticketPrice }"
								id="price${u.sceneryId}" name="price" style="border: none;" /></td>
							<td><input type="text" value="${u.sceneryPosition }"
								id="position${u.sceneryId}" name="position"
								style="border: none;" /></td>

							<td><img src="ImgshowSceneryServlet?fileName=${u.sceneryPhoto}" id="img3"
								style="width: 110px; height: 100px;" /></td>


							<td><textarea rows="5" cols="5" name="introduce"
									id="introduce${u.sceneryId}" style="border: none;">${u.sceneryIntroduce }</textarea>
							</td>




							<td><p>
									<a
										href="DeleteSceneryServlet?sceneryId=${u.sceneryId}&page=${page}"  onclick="shanchu()">删除</a>
								</p>
								<p>
									<a onclick="xg(${u.sceneryId})">修改</a>
								</p></td>
							<script type="text/javascript">
								function xg(idxg) {
									var id = $("#id" + idxg).val();
									var name = $("#name" + idxg).val();
									var price = $("#price" + idxg).val();
									var position = $("#position" + idxg).val();
									var introduce = $("#introduce" + idxg).val();
									$.ajax({
										url : "UpdateSceneryServlet",
										type : "get",
										data : {
											id : id,
											name : name,
											price : price,
											position : position,
											introduce : introduce
										},
										success : function(data) {
											if (data = 1) {
												alert("修改成功");
											} else {
												alert("修改失败");
											}
							
										},
										error : function(data) {
											alert("修改失败");
										}
									});
								}
							</script>
								</tr>
							</c:forEach>
						</table>
						<div class="list-page">
							共${totalNumber}条记录，当前第${pageIndex}/${pageTotalNumber }页 <a
								href="AdminGetScenery?keyword=${param.keyword }&page=1">首页</a> <a
								href="AdminGetScenery?keyword=${param.keyword }&page=${pageIndex-1<1?1:pageIndex-1}">上一页</a>
							<a
								href="AdminGetScenery?keyword=${param.keyword }&page=${pageIndex+1>pageTotalNumber?pageTotalNumber:pageIndex+1}">下一页</a>
							<a
								href="AdminGetScenery?keyword=${param.keyword }&page=${pageTotalNumber}">尾页</a>
						</div>
					</div>
				</form>
			</div>
		</div>
		<!--/main-->
	</div>
</body>
</html>